Opened 12 years ago
Closed 12 years ago
#2173 closed defect (fixed)
ST_Split fails to split on existing vertex
Reported by: | strk | Owned by: | pramsey |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS 2.0.3 |
Component: | postgis | Version: | 2.0.x |
Keywords: | history | Cc: |
Description
This bug was found in #2172 as it affects topology building. In that case a line (899.112421269008 units long) gets splitted by one if its vertices which is around halfway into it:
select st_line_locate_point(geom, st_pointn(geom, 745)) from offending; 0.692338478022024
The return from ST_Split, unioned back togheter, does NOT give the original geometry back.
This is most likely due to the fact that the split is not occurring exactly where the original vertex is but rather on a close-by point which results in snapping a segment on the new point.
Change History (7)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
Further reduction:
Geom: 01020000001000000034030F8FB15866C0F2311FFD3B9A53C0571C87CF1BB65BC0182DB847DB9052C0EBD57BDEEBF658C05CA18B9FA81B52C074384E71C20552C05AD308B7C38351C0A4B3920AA7914CC0ACD200FB29784FC0F8892AEE70E14040C0C8143E325651C0234604DC104E5440EF10F2807BF850C08FEE52B6CAE15F4002BF1C6676B450C0051A57A65BB061405B9E445AEC9F50C05AF3E1D5815665405E3A4A2BB6CF51C0591DE7ECD21F66400D33BFE91C7E53C0000000E0FF7F6640000000C04E9353C0000000000080664000000000008056C000000000008066C000000000008056C000000000008066C0000000E04D9353C034030F8FB15866C0F2311FFD3B9A53C0 Split point: 14
Or in a self-contained test:
with inp as ( SELECT '01020000001000000034030F8FB15866C0F2311FFD3B9A53C0571C87CF1BB65BC0182DB847DB9052C0EBD57BDEEBF658C05CA18B9FA81B52C074384E71C20552C05AD308B7C38351C0A4B3920AA7914CC0ACD200FB29784FC0F8892AEE70E14040C0C8143E325651C0234604DC104E5440EF10F2807BF850C08FEE52B6CAE15F4002BF1C6676B450C0051A57A65BB061405B9E445AEC9F50C05AF3E1D5815665405E3A4A2BB6CF51C0591DE7ECD21F66400D33BFE91C7E53C0000000E0FF7F6640000000C04E9353C0000000000080664000000000008056C000000000008066C000000000008056C000000000008066C0000000E04D9353C034030F8FB15866C0F2311FFD3B9A53C0' ::geometry as g, 14 as p ) select st_equals( g, st_union( st_geometryn(st_split(g, st_pointn(g,p)), 1), st_geometryn(st_split(g, st_pointn(g,p)), 2) ) ) from inp;
comment:3 by , 12 years ago
NOTE: the self-contained test above should return TRUE, and does return TRUE on a 64bit linux, but returns FALSE on a 32bit linux.
comment:4 by , 12 years ago
NOTE: location of the vertex on the line is near the end. Line_Locate_Point returns 0.9827344+ for it.
comment:5 by , 12 years ago
I think the solution here would be to make available (at least at the liblwgeom level) a more robust line location computer that reports distance on a local segment rather than on the whole line. This would be a pair composed by vertex index _and_ distance from the vertex. Any exact vertex would have a distance of 0, for full robustness of those cases.
comment:6 by , 12 years ago
Another solution (short term) is to augment the "vertex snap tolerance" used in the lwline_split_by_point_to function. Currently it uses a tolerance of 1e-14, setting to 1e-13 fixes this case. We could compute a tolerance based on input line length (longer line, higher tolerance).
comment:7 by , 12 years ago
Keywords: | history added |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Reduced input: